﻿#region Using directives

using System;

#endregion

namespace NetROS.Tiers.Entities
{	
	///<summary>
	/// An object representation of the 'tblShemaKnjizenjaRobno' table. [No description found the database]	
	///</summary>
	/// <remarks>
	/// This file is generated once and will never be overwritten.
	/// </remarks>	
	[Serializable]
	[CLSCompliant(true)]
	public partial class ShemaKnjizenjaRobno : ShemaKnjizenjaRobnoBase
	{		
		#region Constructors

		///<summary>
		/// Creates a new <see cref="ShemaKnjizenjaRobno"/> instance.
		///</summary>
		public ShemaKnjizenjaRobno():base(){}

        protected override void AddValidationRules()
        {
            base.AddValidationRules();
        	//Validation rules based on database schema.

          //  ValidationRules.AddRule(ValidateDatumOdzaSifruNijeUIntervalima, new NetROS.Tiers.Entities.Validation.ValidationRuleArgs("KontoZaPrebacivanje", "KontoZaPrebacivanje"));
		}
        private bool ValidateDatumOdzaSifruNijeUIntervalima(object target, NetROS.Tiers.Entities.Validation.ValidationRuleArgs e)
        {
            if (this.ParentCollection != null && this.ParentCollection as TList<ShemaKnjizenjaRobno> != null)
            {
                TList<ShemaKnjizenjaRobno> _tlist = this.ParentCollection as TList<ShemaKnjizenjaRobno>;
                foreach (ShemaKnjizenjaRobno _shema in _tlist)
                {
                    if (_shema != this)
                    {
                        if (_shema.IDDokumentTip == this.IDDokumentTip && _shema.KontoZaPrebacivanje == this.KontoZaPrebacivanje && _shema.DugIliPot == this.DugIliPot)
                        {
                            e.Description = "Konto i strana već izbrana za taj tip dokumenta";
                            return false;
                        }
                    }
                    
                }
            }
            return true;
        }


	    #endregion
	}
}
